/*
 Navicat Premium Data Transfer

 Source Server         : 192.168.1.55-root
 Source Server Type    : MySQL
 Source Server Version : 50716
 Source Host           : 192.168.1.55
 Source Database       : heb

 Target Server Type    : MySQL
 Target Server Version : 50716
 File Encoding         : utf-8

 Date: 06/19/2017 15:01:18 PM
*/

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
--  Table structure for `base_car`
-- ----------------------------
DROP TABLE IF EXISTS `base_car`;
CREATE TABLE `base_car` (
  `create_at` datetime DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `is_deleted` tinyint(1) DEFAULT NULL,
  `memo` varchar(255) DEFAULT NULL,
  `dept_id` bigint(20) DEFAULT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_car_no` varchar(10) DEFAULT NULL COMMENT '车牌号',
  `base_car_no_colour` tinyint(3) DEFAULT NULL COMMENT '车牌号颜色[1-4]黄白蓝黑',
  `base_car_brand` varchar(100) DEFAULT NULL COMMENT '车辆品牌',
  `base_car_type_id` bigint(20) DEFAULT NULL COMMENT '车辆类型id－面包车、轿车等',
  `base_car_output` decimal(2,1) DEFAULT NULL COMMENT '排量',
  `base_car_icon_id` bigint(20) DEFAULT NULL COMMENT '车辆图标',
  `base_terminal_id` bigint(32) NOT NULL COMMENT '设备id',
  `user_name` varchar(20) DEFAULT NULL COMMENT '车主姓名',
  `user_phone` varchar(20) DEFAULT NULL COMMENT '车主电话',
  `base_car_name` varchar(100) DEFAULT NULL COMMENT '车辆别名',
  `base_car_fd_no` varchar(50) DEFAULT NULL COMMENT '发动机号',
  `base_car_jj_no` varchar(50) DEFAULT NULL COMMENT '机架号',
  `base_car_rl_type` varchar(10) DEFAULT NULL COMMENT '燃料类型  1-汽油 2- 柴油 3-新能源',
  `base_car_of_province` varchar(100) DEFAULT NULL COMMENT '所属省份',
  `base_car_of_city` varchar(100) DEFAULT NULL COMMENT '所属市区',
  `base_car_dis` double(20,2) DEFAULT NULL COMMENT '初始里程',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COMMENT='车辆基本信息';

-- ----------------------------
--  Records of `base_car`
-- ----------------------------
BEGIN;
INSERT INTO `base_car` VALUES (null, '2017-06-16 20:41:07', null, 'admin', '0', null, '1', '29', '鲁Bqssamson', '1', '1', '1', '1.3', '1', '1', 'mgd', '13685323176', 'test', '12344444', '55555556666', '柴油', 'shangdong', 'qd', '0.00');
COMMIT;

-- ----------------------------
--  Table structure for `base_car_common_set`
-- ----------------------------
DROP TABLE IF EXISTS `base_car_common_set`;
CREATE TABLE `base_car_common_set` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `carid` bigint(20) NOT NULL COMMENT '车辆ID',
  `is_speed` tinyint(1) DEFAULT '0' COMMENT '是否开启超速',
  `speed_limited` int(4) NOT NULL COMMENT '限速值',
  `is_stop` tinyint(1) DEFAULT '0' COMMENT '是否开启停车报警',
  `stop_limited` int(4) NOT NULL COMMENT '限时值',
  `is_wee_hours` tinyint(1) DEFAULT '0' COMMENT '是否开启凌晨2-5报警',
  `is_fatigue` tinyint(1) DEFAULT '0' COMMENT '是否开启疲劳驾驶报警',
  `driver_limited_time` int(10) NOT NULL COMMENT '连续驾驶限时值/秒',
  `rest_limited_time` int(10) NOT NULL COMMENT '最小休息时间/秒',
  `is_deleted` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='通用报警基本信息';

-- ----------------------------
--  Table structure for `base_car_type`
-- ----------------------------
DROP TABLE IF EXISTS `base_car_type`;
CREATE TABLE `base_car_type` (
  `create_at` datetime DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `is_deleted` tinyint(1) DEFAULT NULL,
  `memo` varchar(255) DEFAULT NULL,
  `dept_id` bigint(20) DEFAULT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_car_type` varchar(20) DEFAULT NULL COMMENT '车辆类型－轿车、商务等',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='车辆类型信息';

-- ----------------------------
--  Records of `base_car_type`
-- ----------------------------
BEGIN;
INSERT INTO `base_car_type` VALUES (null, null, null, null, '0', null, '1', '1', '上海通用别克');
COMMIT;

-- ----------------------------
--  Table structure for `base_common_fence`
-- ----------------------------
DROP TABLE IF EXISTS `base_common_fence`;
CREATE TABLE `base_common_fence` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `fence_type` tinyint(4) NOT NULL COMMENT '围栏类型 1-兴趣点 2-区域圆形 3-区域多边形 4-路线折线',
  `contentinfo` varchar(8000) NOT NULL COMMENT 'type=1 jd,wd type=2 jd,wd;R type=3 jd1,wd1;jd2,wd2;....  type=4 同type=3',
  `is_deleted` tinyint(1) DEFAULT '0',
  `settingname` varchar(90) DEFAULT NULL COMMENT '名称',
  `line_time` int(5) NOT NULL COMMENT '线路预计耗时(分钟)',
  `memo` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='电子围栏基本信息';

-- ----------------------------
--  Records of `base_common_fence`
-- ----------------------------
BEGIN;
INSERT INTO `base_common_fence` VALUES ('1', '1', '120.299111,36.292036', '1', '标注01', '0', '120.299111,36.292036'), ('2', '1', '120.590594,36.217064', '0', '点01', '0', '120.590594,36.217064'), ('3', '2', '120.364652,36.27202;5413.373269316043', '0', '园01', '0', '120.364652,36.27202;5413.373269316043'), ('4', '4', '120.506081,36.269226;120.482509,36.237095;120.509531,36.199824;120.480785,36.181648;120.507231,36.142952;120.47791,36.132226', '0', '线01', '20', '120.4937205,36.200726'), ('5', '3', '120.254843,36.300879;120.252543,36.251067;120.303711,36.253861;120.326132,36.291105;120.303136,36.348799', '0', '多边形01', '0', '120.2893375,36.299932999999996'), ('6', '3', '120.306585,36.37298;120.388798,36.37298;120.388798,36.320423;120.306585,36.320423', '0', '举行01', '0', '120.3476915,36.346701499999995');
COMMIT;

-- ----------------------------
--  Table structure for `base_fence_manager`
-- ----------------------------
DROP TABLE IF EXISTS `base_fence_manager`;
CREATE TABLE `base_fence_manager` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `carid` bigint(20) NOT NULL COMMENT '车辆id',
  `fenceid` bigint(20) NOT NULL COMMENT '围栏id',
  `is_driver_type` tinyint(3) DEFAULT '0' COMMENT '0-驶入报警 1-驶出报警 2-驶入驶出报警 3-偏离报警',
  `pl_dis` int(5) DEFAULT '10' COMMENT '偏离限值',
  `is_deleted` tinyint(1) DEFAULT '0',
  `settingcount` int(3) DEFAULT '1' COMMENT '次数限值',
  `limited_begintime` datetime NOT NULL,
  `limited_endtime` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='车辆关联电子围栏管理信息';

-- ----------------------------
--  Records of `base_fence_manager`
-- ----------------------------
BEGIN;
INSERT INTO `base_fence_manager` VALUES ('2', '29', '2', '0', '222', '0', '222', '2017-06-18 17:11:13', '2017-06-18 17:11:13');
COMMIT;

-- ----------------------------
--  Table structure for `base_terminal`
-- ----------------------------
DROP TABLE IF EXISTS `base_terminal`;
CREATE TABLE `base_terminal` (
  `create_at` datetime DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `is_deleted` tinyint(1) DEFAULT NULL,
  `memo` varchar(255) DEFAULT NULL COMMENT '备注',
  `dept_id` bigint(20) DEFAULT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_terminal_id` varchar(30) DEFAULT NULL COMMENT ' 终端id',
  `base_terminal_sim` varchar(11) DEFAULT NULL COMMENT 'sim卡号',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='终端设备管理';

-- ----------------------------
--  Records of `base_terminal`
-- ----------------------------
BEGIN;
INSERT INTO `base_terminal` VALUES ('2017-06-13 20:04:07', '2017-06-16 20:53:36', 'admin', 'admin', '0', '321', '1', '1', '99778866', '13366779821');
COMMIT;

-- ----------------------------
--  Table structure for `base_work_info`
-- ----------------------------
DROP TABLE IF EXISTS `base_work_info`;
CREATE TABLE `base_work_info` (
  `create_at` datetime DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `is_deleted` tinyint(1) DEFAULT NULL,
  `memo` varchar(255) DEFAULT NULL,
  `dept_id` bigint(20) DEFAULT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_work_name` varchar(20) DEFAULT NULL COMMENT '工作别名',
  `base_work_begintime` datetime DEFAULT NULL COMMENT '上班时间',
  `base_work_endtime` datetime DEFAULT NULL COMMENT '下班时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='车辆类型信息';

-- ----------------------------
--  Table structure for `bus_pass_line`
-- ----------------------------
DROP TABLE IF EXISTS `bus_pass_line`;
CREATE TABLE `bus_pass_line` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `carid` bigint(20) NOT NULL COMMENT '车辆id',
  `fenceid` bigint(20) NOT NULL COMMENT '围栏id',
  `jd` varchar(20) DEFAULT NULL COMMENT '经度',
  `wd` varchar(20) DEFAULT NULL COMMENT '纬度',
  `is_deleted` tinyint(1) DEFAULT '0',
  `pass_time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='车辆途径线路统计表';

-- ----------------------------
--  Table structure for `bus_terminal_data`
-- ----------------------------
DROP TABLE IF EXISTS `bus_terminal_data`;
CREATE TABLE `bus_terminal_data` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_terminal_id` varchar(30) NOT NULL COMMENT '车载设备编号',
  `gpsDate` datetime DEFAULT NULL COMMENT '时间',
  `wd` varchar(20) DEFAULT NULL COMMENT '纬度',
  `jd` varchar(20) DEFAULT NULL COMMENT '经度',
  `speed` double DEFAULT NULL COMMENT '速度',
  `driection` varchar(20) DEFAULT NULL COMMENT '方向',
  `gpsDataFlag` tinyint(3) DEFAULT NULL COMMENT '定位成功',
  `gpsFlag` tinyint(3) DEFAULT NULL COMMENT 'GPS天线状态',
  `gpsPowerStatus` tinyint(3) DEFAULT NULL COMMENT 'GPS电源状态',
  `totalDis` decimal(20,2) DEFAULT NULL COMMENT '里程',
  `monthDis` double(9,0) DEFAULT NULL COMMENT '月里程',
  `dayDis` double(9,0) DEFAULT NULL COMMENT '日里程',
  `accFlag` tinyint(3) DEFAULT NULL COMMENT '点火状态',
  `oneHigh` tinyint(3) DEFAULT NULL,
  `twoHigh` tinyint(3) DEFAULT NULL,
  `oneLow` tinyint(3) DEFAULT NULL,
  `twoLow` tinyint(3) DEFAULT NULL,
  `oilFlag` tinyint(3) DEFAULT NULL COMMENT '油路状态',
  `oilType` tinyint(3) DEFAULT NULL COMMENT '油路控制模式',
  `theftAlarm` tinyint(3) DEFAULT NULL COMMENT '劫警',
  `speeding` tinyint(3) DEFAULT NULL COMMENT '超速报警',
  `stoping` tinyint(3) DEFAULT NULL COMMENT '停车报警',
  `online` tinyint(3) DEFAULT NULL COMMENT '0离线1在线',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4462 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `bus_terminal_data`
-- ----------------------------
BEGIN;
INSERT INTO `bus_terminal_data` VALUES ('4461', '8690069028', '2017-06-07 15:16:05', '36.09718201760323', '120.37827416347707', '0', '正北', '1', null, null, '0.00', '0', '0', '0', null, null, null, null, null, null, null, null, null, '1');
COMMIT;

-- ----------------------------
--  Table structure for `bus_terminal_his_data`
-- ----------------------------
DROP TABLE IF EXISTS `bus_terminal_his_data`;
CREATE TABLE `bus_terminal_his_data` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `base_terminal_id` varchar(30) NOT NULL COMMENT '车载设备编号',
  `gpsDate` datetime DEFAULT NULL COMMENT '时间',
  `wd` varchar(20) DEFAULT NULL COMMENT '纬度',
  `jd` varchar(20) DEFAULT NULL COMMENT '经度',
  `speed` decimal(8,2) DEFAULT NULL COMMENT '速度',
  `driection` varchar(20) DEFAULT NULL COMMENT '方向',
  `gpsDataFlag` tinyint(1) DEFAULT NULL COMMENT '定位成功',
  `gpsFlag` tinyint(1) DEFAULT NULL COMMENT 'GPS天线状态',
  `gpsPowerStatus` tinyint(1) DEFAULT NULL COMMENT 'GPS电源状态',
  `totalDis` decimal(20,2) DEFAULT NULL COMMENT '里程',
  `accFlag` tinyint(1) DEFAULT NULL COMMENT '点火状态',
  `oneHigh` tinyint(1) DEFAULT NULL,
  `twoHigh` tinyint(1) DEFAULT NULL,
  `oneLow` tinyint(1) DEFAULT NULL,
  `twoLow` tinyint(1) DEFAULT NULL,
  `oilFlag` tinyint(1) DEFAULT NULL COMMENT '油路状态',
  `oilType` tinyint(1) DEFAULT NULL COMMENT '油路控制模式',
  `theftAlarm` tinyint(1) DEFAULT NULL COMMENT '劫警',
  `speeding` tinyint(1) DEFAULT NULL COMMENT '超速报警',
  `stoping` tinyint(1) DEFAULT NULL COMMENT '停车报警',
  `online` tinyint(3) DEFAULT '1',
  `base_car_no` varchar(30) DEFAULT '123',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4497 DEFAULT CHARSET=utf8;

-- ----------------------------
--  Records of `bus_terminal_his_data`
-- ----------------------------
BEGIN;
INSERT INTO `bus_terminal_his_data` VALUES ('4496', '8690069028', '2017-06-07 15:16:05', '36.09718201760323', '120.37827416347707', '0.00', '正北', '1', null, null, '0.00', null, null, '0', null, null, null, null, null, null, null, '1', '123');
COMMIT;

-- ----------------------------
--  Table structure for `s_dept`
-- ----------------------------
DROP TABLE IF EXISTS `s_dept`;
CREATE TABLE `s_dept` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) DEFAULT NULL COMMENT '部门名称',
  `parent_name` varchar(20) DEFAULT NULL COMMENT '父节点名称',
  `code` varchar(20) DEFAULT NULL COMMENT '编码',
  `memo` varchar(255) DEFAULT NULL COMMENT '备注',
  `parent_id` bigint(20) NOT NULL COMMENT '父资源',
  `is_deleted` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门';

-- ----------------------------
--  Records of `s_dept`
-- ----------------------------
BEGIN;
INSERT INTO `s_dept` VALUES ('1', '市政府', '青岛市', '001', '系统默认', '-1', '0'), ('2', '1', '市政府', '2', '2', '1', '1'), ('3', '1', '所有部门', '0012', '11', '-1', '1'), ('4', '1', '市政府', '1', '1', '1', '1'), ('5', '1', '所有部门', '111', null, '-1', '1'), ('6', '1', '所有部门', '1', '1', '-1', '1'), ('7', '1', '所有部门', '11', null, '-1', '1'), ('8', '11', '所有部门', '22', null, '-1', '1'), ('9', '2', '所有部门', '2', '2', '-1', '1'), ('10', '3', '所有部门', '3', null, '-1', '1'), ('11', '哈工大后勤集团', '所有部门', '002', null, '-1', '0'), ('12', '后勤一部门', '哈工大后勤集团', '00199', '后勤1', '11', '0');
COMMIT;

-- ----------------------------
--  Table structure for `s_emp`
-- ----------------------------
DROP TABLE IF EXISTS `s_emp`;
CREATE TABLE `s_emp` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) DEFAULT NULL COMMENT '名称',
  `addr` varchar(255) DEFAULT NULL COMMENT '地址',
  `phone` varchar(20) DEFAULT NULL COMMENT '电话',
  `memo` varchar(255) DEFAULT NULL COMMENT '备注',
  `user_id` bigint(20) DEFAULT NULL COMMENT '登录用户id',
  `dept_id` bigint(20) NOT NULL COMMENT '父资源',
  `login_name` varchar(30) DEFAULT NULL COMMENT '登录账号',
  `is_deleted` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门';

-- ----------------------------
--  Records of `s_emp`
-- ----------------------------
BEGIN;
INSERT INTO `s_emp` VALUES ('13', 'admin', 'admin', '13899922292', null, '1', '1', 'admin', '0'), ('14', '用车人', '用车人', '12388882838', null, '3', '1', null, '1'), ('15', '用车申请人', '用车申请人', '13900202021', null, '12', '1', '21010023', '0'), ('16', '用车审核人', '用车审核人', '13900222002', null, '13', '1', '21010024', '0'), ('17', '用车调度人', '用车调度人', '13899292929', null, '14', '1', '21010025', '0'), ('18', '驾驶员', '驾驶员', '13332222232', null, '18', '1', '21010026', '0');
COMMIT;

-- ----------------------------
--  Table structure for `s_operate`
-- ----------------------------
DROP TABLE IF EXISTS `s_operate`;
CREATE TABLE `s_operate` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `op_code` varchar(10) DEFAULT '00',
  `op_name` varchar(50) NOT NULL COMMENT '操作名称\n\n',
  `action_name` varchar(50) DEFAULT NULL COMMENT 'action名称',
  `memo` varchar(255) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='操作定义';

-- ----------------------------
--  Records of `s_operate`
-- ----------------------------
BEGIN;
INSERT INTO `s_operate` VALUES ('1', '001', '菜单操作', null, null), ('2', '002', '显示功能页面', null, null), ('3', '003', '操作', '', null);
COMMIT;

-- ----------------------------
--  Table structure for `s_privilege`
-- ----------------------------
DROP TABLE IF EXISTS `s_privilege`;
CREATE TABLE `s_privilege` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `res_id` bigint(20) NOT NULL COMMENT '资源ID, s_res.id',
  `op_id` bigint(20) NOT NULL COMMENT '操作ID, s_operate.id',
  `is_free` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否不进行权限控制，0-否（默认）1-是。为1时，不做权限控制。',
  PRIMARY KEY (`id`),
  KEY `fk_s_privilege_s_res1_idx` (`res_id`),
  KEY `fk_s_privilege_s_operate1_idx` (`op_id`),
  CONSTRAINT `s_privilege_ibfk_1` FOREIGN KEY (`op_id`) REFERENCES `s_operate` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `s_privilege_ibfk_2` FOREIGN KEY (`res_id`) REFERENCES `s_res` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='权限定义表';

-- ----------------------------
--  Records of `s_privilege`
-- ----------------------------
BEGIN;
INSERT INTO `s_privilege` VALUES ('1', '1', '1', '0'), ('5', '2', '1', '0'), ('6', '3', '1', '0'), ('7', '4', '1', '0'), ('10', '8', '1', '0'), ('16', '15', '1', '0'), ('21', '20', '1', '0'), ('25', '24', '1', '0'), ('42', '42', '1', '0');
COMMIT;

-- ----------------------------
--  Table structure for `s_res`
-- ----------------------------
DROP TABLE IF EXISTS `s_res`;
CREATE TABLE `s_res` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `package_name` varchar(50) NOT NULL COMMENT '子系统默认包名，用于区分子系统',
  `res_code` varchar(10) DEFAULT '00',
  `res_name` varchar(50) NOT NULL COMMENT '资源名称',
  `controller_name` varchar(50) DEFAULT NULL COMMENT 'Controller名称',
  `memo` varchar(255) DEFAULT NULL COMMENT '备注',
  `parent_id` bigint(20) NOT NULL COMMENT '父资源',
  `res_status` tinyint(3) unsigned NOT NULL COMMENT '资源状态\n0-正常\n1-停用',
  `res_type` tinyint(3) NOT NULL DEFAULT '3' COMMENT '资源类型：1-正式发布，2-预览，3-测试',
  `leaf` tinyint(1) DEFAULT '0' COMMENT '子节点0否1是',
  `icon_cls` varchar(255) DEFAULT NULL COMMENT '图标样式',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统资源';

-- ----------------------------
--  Records of `s_res`
-- ----------------------------
BEGIN;
INSERT INTO `s_res` VALUES ('1', 'gps.pro', '10', '首页', '/home', '', '0', '0', '1', '1', 'x-fa fa-desktop'), ('2', 'gps.pro', '20', '实时监控', '/map', '', '0', '0', '1', '1', 'x-fa fa-send'), ('3', 'gps.pro', '30', '车辆调度', 'busCarScheduleMain', '0', '0', '0', '1', '0', 'x-fa fa-car'), ('4', 'gps.pro', '40', '用车管理', 'allAppalyManager', '1', '0', '0', '1', '1', 'x-fa fa-car'), ('8', 'gps.pro', '50', '经费结算', 'allmoneymanagermain', '', '0', '0', '1', '0', 'x-fa fa-send'), ('15', 'gps.pro', '60', '车务管理', 'carbusinessmanagermain', '', '0', '0', '1', '0', 'x-fa fa-car'), ('16', 'gps.pro', '61', '车务管理-审核', 'carbusinessmanagermain', '', '0', '1', '1', '0', 'x-fa fa-car'), ('17', 'gps.pro', '62', '车务管理-调度', 'carbusinessmanagermain', '', '0', '1', '1', '0', 'x-fa fa-car'), ('20', 'gps.pro', '70', '安全管理', 'safemanagermain', '', '0', '0', '1', '0', 'x-fa fa-car'), ('24', 'gps.pro', '80', '后台管理', 'backmanagermain', '', '0', '0', '1', '0', 'x-fa fa-search'), ('42', 'gps.pro', '71', '统计分析管理', 'allReportManager', '', '0', '0', '1', '1', 'x-fa fa-search');
COMMIT;

-- ----------------------------
--  Table structure for `s_role`
-- ----------------------------
DROP TABLE IF EXISTS `s_role`;
CREATE TABLE `s_role` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `package_name` varchar(20) NOT NULL COMMENT '子系统默认包名，用于区分子系统',
  `tenant_id` bigint(19) unsigned DEFAULT NULL COMMENT '客户ID，saas系统为0',
  `role_code` varchar(20) DEFAULT NULL COMMENT '角色编码',
  `role_name` varchar(50) NOT NULL COMMENT '角色名称\n\n',
  `create_by` varchar(50) DEFAULT NULL,
  `create_at` datetime DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色信息';

-- ----------------------------
--  Records of `s_role`
-- ----------------------------
BEGIN;
INSERT INTO `s_role` VALUES ('1', 'smart.light.web', '0', '01', '管理员', null, null, null, null, '0'), ('2', 'smart.light.web', '0', '02', '申请人', null, null, null, null, '0'), ('4', 'smart.light.web', '0', '04', '调度员', null, null, null, null, '0'), ('19', 'smart.light.web', '0', '05', '审核员', null, null, null, null, '0'), ('20', 'smart.light.web', '0', '06', '驾驶员', null, null, null, null, '0'), ('21', 'smart.light.web', null, '07', '111', null, null, null, null, '1');
COMMIT;

-- ----------------------------
--  Table structure for `s_role_privilege_r`
-- ----------------------------
DROP TABLE IF EXISTS `s_role_privilege_r`;
CREATE TABLE `s_role_privilege_r` (
  `role_id` bigint(20) NOT NULL COMMENT '角色ID，s_role.id',
  `privilege_id` bigint(20) NOT NULL COMMENT '权限ID，s_privilege.id',
  `limit_date` date DEFAULT NULL COMMENT '使用期限',
  `is_disable` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`role_id`,`privilege_id`),
  KEY `fk_s_role_privilege_s_role1_idx` (`role_id`) USING BTREE,
  KEY `fk_s_role_privilege_s_privilege1_idx` (`privilege_id`) USING BTREE,
  CONSTRAINT `s_role_privilege_r_ibfk_1` FOREIGN KEY (`privilege_id`) REFERENCES `s_privilege` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `s_role_privilege_r_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `s_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色权限关系表';

-- ----------------------------
--  Records of `s_role_privilege_r`
-- ----------------------------
BEGIN;
INSERT INTO `s_role_privilege_r` VALUES ('1', '1', null, '0'), ('1', '5', null, '0'), ('1', '6', null, '0'), ('1', '7', null, '0'), ('1', '10', null, '0'), ('1', '16', null, '0'), ('1', '21', null, '0'), ('1', '25', null, '0'), ('1', '42', null, '0'), ('2', '1', null, '0'), ('2', '7', null, '0'), ('4', '1', null, '0'), ('4', '5', null, '0'), ('4', '6', null, '0'), ('4', '7', null, '0'), ('16', '3', null, '0'), ('16', '4', null, '0'), ('16', '10', null, '0'), ('16', '11', null, '0'), ('16', '12', null, '0'), ('16', '13', null, '0'), ('16', '14', null, '0'), ('16', '15', null, '0'), ('16', '16', null, '0'), ('16', '17', null, '0'), ('16', '18', null, '0'), ('16', '19', null, '0'), ('16', '20', null, '0'), ('16', '21', null, '0'), ('16', '22', null, '0'), ('16', '23', null, '0'), ('16', '25', null, '0'), ('16', '26', null, '0'), ('16', '27', null, '0'), ('16', '28', null, '0'), ('16', '29', null, '0'), ('16', '30', null, '0'), ('16', '31', null, '0'), ('16', '32', null, '0'), ('19', '1', null, '0'), ('19', '7', null, '0'), ('20', '1', null, '0'), ('20', '7', null, '0');
COMMIT;

-- ----------------------------
--  Table structure for `s_user`
-- ----------------------------
DROP TABLE IF EXISTS `s_user`;
CREATE TABLE `s_user` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '唯一ID，自增',
  `login_name` varchar(30) NOT NULL COMMENT '登录帐号',
  `login_pass` varchar(32) DEFAULT NULL COMMENT '登录密码（32位md5加密）',
  `user_type` tinyint(3) unsigned NOT NULL COMMENT '用户类型（1-后台账号，2app账号；）',
  `bind_mobile` varchar(20) DEFAULT NULL COMMENT '用户绑定的手机号',
  `bind_wechat` varchar(64) DEFAULT NULL COMMENT '用户绑定的微信号OpenID',
  `bind_email` varchar(50) DEFAULT NULL,
  `bind_qq` varchar(20) DEFAULT NULL,
  `state` tinyint(3) unsigned NOT NULL COMMENT '用户状态（0-未激活；1-启用；2-停用）未激活的帐号为无效帐号，3分钟后可重复注册',
  `name` varchar(50) DEFAULT NULL COMMENT '姓名',
  `login_count` int(11) DEFAULT '0' COMMENT '登录次数',
  `last_login_time` datetime DEFAULT NULL COMMENT '上次登录时间',
  `last_login_ip` varchar(20) DEFAULT NULL COMMENT '上次登录IP',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
  `create_at` datetime DEFAULT NULL,
  `create_by` varchar(50) DEFAULT NULL,
  `last_update_at` datetime DEFAULT NULL,
  `last_update_by` varchar(50) DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户表';

-- ----------------------------
--  Records of `s_user`
-- ----------------------------
BEGIN;
INSERT INTO `s_user` VALUES ('1', 'admin', '21218cca77804d2ba1922c33e0151105', '1', '12333322222', null, null, null, '1', '管理员用户', '656', '2017-06-19 14:50:41', '127.0.0.1', null, '2016-04-13 15:21:09', null, '2016-04-13 15:21:09', null, '0'), ('2', '21010021', '21218cca77804d2ba1922c33e0151105', '2', '18562596297', null, null, null, '1', '驾驶员', '0', null, null, null, '2016-07-17 09:45:25', null, '2016-07-17 09:45:25', null, '0'), ('3', '21010022', '21218cca77804d2ba1922c33e0151105', '1', '18553250021', null, null, null, '2', '申请人', '0', null, null, null, '2016-07-17 09:45:49', null, '2016-07-17 09:45:49', null, '0'), ('4', '61011001', 'e10adc3949ba59abbe56e057f20f883e', '2', '13685323177', null, null, null, '1', 'pippo', '0', null, null, null, '2016-09-18 15:46:46', null, '2016-09-18 15:46:46', null, '0'), ('5', '61011002', '21218cca77804d2ba1922c33e0151105', '2', '13354566788', null, null, null, '1', 'lee', '0', null, null, null, '2016-11-02 14:27:14', null, '2016-11-02 14:27:14', null, '0'), ('6', '61011003', '21218cca77804d2ba1922c33e0151105', '2', '13344556677', null, null, null, '1', 'lee', '0', null, null, null, '2016-11-02 14:30:01', null, '2016-11-02 14:30:01', null, '0'), ('7', '61011004', '21218cca77804d2ba1922c33e0151105', '2', '12234567891', null, null, null, '1', 'asd', '0', null, null, null, '2016-11-02 15:28:14', null, '2016-11-02 15:28:14', null, '0'), ('8', '61011006', '21218cca77804d2ba1922c33e0151105', '2', '13389706654', null, null, null, '1', 'dddd', '0', null, null, null, '2016-11-02 16:44:25', null, '2016-11-02 16:44:25', null, '0'), ('9', '61011007', '21218cca77804d2ba1922c33e0151105', '2', '13300992278', null, null, null, '1', 'eeeee', '0', null, null, null, '2016-11-02 16:48:43', null, '2016-11-02 16:48:43', null, '0'), ('10', '61011008', '21218cca77804d2ba1922c33e0151105', '2', '13322446612', null, null, null, '1', 'FF', '0', null, null, null, '2016-11-02 17:00:16', null, '2016-11-02 17:00:16', null, '0'), ('11', '61011009', '21218cca77804d2ba1922c33e0151105', '2', '13324556671', null, null, null, '1', 'qqwq', '0', null, null, null, '2016-11-02 17:26:09', null, '2016-11-02 17:26:09', null, '0'), ('12', '21010023', '21218cca77804d2ba1922c33e0151105', '1', '13900202021', null, null, null, '1', '用车申请人', '10', '2017-03-03 15:15:37', '112.254.102.117', null, '2016-11-22 11:07:46', null, '2016-11-22 11:07:46', null, '0'), ('13', '21010024', '21218cca77804d2ba1922c33e0151105', '1', '13900222002', null, null, null, '1', '用车审核人', '6', '2016-11-23 15:31:13', '0:0:0:0:0:0:0:1', null, '2016-11-22 11:08:16', null, '2016-11-22 11:08:16', null, '0'), ('14', '21010025', '21218cca77804d2ba1922c33e0151105', '1', '13899292929', null, null, null, '1', '用车调度人', '14', '2016-11-24 11:18:45', '0:0:0:0:0:0:0:1', null, '2016-11-22 11:08:47', null, '2016-11-22 11:08:47', null, '0'), ('15', '61011010', '21218cca77804d2ba1922c33e0151105', '2', '13902828828', null, null, null, '1', '驾驶员-01', '1', '2016-11-22 15:19:58', '127.0.0.1', null, '2016-11-22 11:10:08', null, '2016-11-22 11:10:08', null, '0'), ('16', '61011011', '21218cca77804d2ba1922c33e0151105', '2', '13888282828', null, null, null, '1', '驾驶员-02', '0', null, null, null, '2016-11-22 11:11:35', null, '2016-11-22 11:11:35', null, '0'), ('17', '61011012', '21218cca77804d2ba1922c33e0151105', '2', '111333', null, null, null, '1', '驾驶员-03', '0', null, null, null, '2016-11-22 11:12:29', null, '2016-11-22 11:12:29', null, '0'), ('18', '21010026', '21218cca77804d2ba1922c33e0151105', '1', '13332222232', null, null, null, '1', '驾驶员', '5', '2017-03-16 09:33:08', '27.223.110.230', null, '2016-11-22 16:07:37', null, '2016-11-22 16:07:37', null, '1');
COMMIT;

-- ----------------------------
--  Table structure for `s_user_role_r`
-- ----------------------------
DROP TABLE IF EXISTS `s_user_role_r`;
CREATE TABLE `s_user_role_r` (
  `user_id` bigint(20) NOT NULL COMMENT '用户ID，sys_user.id',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID，s_role.id',
  PRIMARY KEY (`user_id`,`role_id`),
  KEY `fk_s_user_role_r_s_role1_idx` (`role_id`),
  KEY `fk_s_user_role_r_sys_user1_idx` (`user_id`),
  CONSTRAINT `s_user_role_r_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `s_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `s_user_role_r_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `s_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户角色关系表';

-- ----------------------------
--  Records of `s_user_role_r`
-- ----------------------------
BEGIN;
INSERT INTO `s_user_role_r` VALUES ('1', '1'), ('6', '1'), ('11', '1'), ('1', '2'), ('2', '2'), ('3', '2'), ('4', '2'), ('5', '2'), ('6', '2'), ('7', '2'), ('8', '2'), ('9', '2'), ('10', '2'), ('11', '2'), ('12', '2'), ('1', '4'), ('3', '4'), ('6', '4'), ('7', '4'), ('9', '4'), ('11', '4'), ('14', '4'), ('6', '5'), ('7', '5'), ('9', '5'), ('3', '12'), ('6', '12'), ('3', '16'), ('6', '16'), ('13', '19'), ('18', '20');
COMMIT;

-- ----------------------------
--  Table structure for `sequence`
-- ----------------------------
DROP TABLE IF EXISTS `sequence`;
CREATE TABLE `sequence` (
  `name` varchar(50) NOT NULL,
  `current_value` int(11) unsigned NOT NULL,
  `increment` int(11) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
--  Records of `sequence`
-- ----------------------------
BEGIN;
INSERT INTO `sequence` VALUES ('dd', '0', '1'), ('tenant', '61011013', '1'), ('tenant_hzg', '71010004', '1'), ('tenant_test', '21010026', '1');
COMMIT;

-- ----------------------------
--  Table structure for `sequence2`
-- ----------------------------
DROP TABLE IF EXISTS `sequence2`;
CREATE TABLE `sequence2` (
  `name` varchar(50) NOT NULL,
  `current_value` int(11) unsigned NOT NULL,
  `seq_date` date NOT NULL,
  `increment` int(11) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
--  Records of `sequence2`
-- ----------------------------
BEGIN;
INSERT INTO `sequence2` VALUES ('dd11', '4', '2016-03-01', '1'), ('dd17', '1', '2016-03-09', '1'), ('dd9', '12', '2016-02-28', '1'), ('SQD1', '2', '2017-04-05', '1');
COMMIT;

-- ----------------------------
--  Table structure for `tab_waring_info`
-- ----------------------------
DROP TABLE IF EXISTS `tab_waring_info`;
CREATE TABLE `tab_waring_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `carID` bigint(20) NOT NULL,
  `waringType` int(11) NOT NULL COMMENT '1-驶入  2-驶出 3-超速 4-路线偏离 5-停车超时报警  6-疲劳驾驶报警 7-凌晨行车报警',
  `is_deleted` tinyint(1) DEFAULT '0',
  `waringtime` datetime DEFAULT NULL,
  `waringcontent` varchar(300) DEFAULT NULL COMMENT '报警内容－－鲁b88888驶入xxx区域',
  `waringstate` tinyint(4) DEFAULT '0' COMMENT '0未处理 1已处理',
  `jd` varchar(30) DEFAULT NULL COMMENT ' 经度',
  `wd` varchar(30) DEFAULT NULL COMMENT '纬度',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='报警';

-- ----------------------------
--  Function structure for `currval`
-- ----------------------------
DROP FUNCTION IF EXISTS `currval`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `currval`(seq_name VARCHAR(50)) RETURNS int(11)
    DETERMINISTIC
BEGIN
         DECLARE VALUE INTEGER;
         SET VALUE = 0;
         SELECT current_value INTO VALUE
                   FROM sequence
                   WHERE NAME = seq_name;
     IF VALUE = 0 THEN
      SET VALUE = 1;
      INSERT INTO sequence(NAME, current_value) VALUES(seq_name, VALUE);
     END IF;
         RETURN VALUE;
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `currval_today`
-- ----------------------------
DROP FUNCTION IF EXISTS `currval_today`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `currval_today`(seq_name VARCHAR(50)) RETURNS int(11)
    DETERMINISTIC
BEGIN
         DECLARE v INTEGER;
         DECLARE dt DATE;
         DECLARE dtCurrent DATE;
         SET v = 0;
         SET dt = NULL;
         SET dtCurrent = CURRENT_DATE();
         SELECT current_value, seq_date INTO v, dt
                   FROM sequence2
                   WHERE NAME = seq_name;
     IF v = 0 THEN
      SET v = 1;
      INSERT INTO sequence2(NAME, current_value, seq_date) VALUES(seq_name, v, dtCurrent);     
         ELSEIF dt <> dtCurrent THEN
      SET v = 1;
            UPDATE sequence2
        SET current_value = v, seq_date = dtCurrent
                WHERE NAME = seq_name;
     END IF;
         RETURN v;
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `nextval`
-- ----------------------------
DROP FUNCTION IF EXISTS `nextval`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `nextval`(seq_name VARCHAR(50)) RETURNS int(11)
    DETERMINISTIC
BEGIN
         UPDATE sequence
                   SET current_value = current_value + increment
                   WHERE NAME = seq_name;
         RETURN currval(seq_name);
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `nextval_today`
-- ----------------------------
DROP FUNCTION IF EXISTS `nextval_today`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `nextval_today`(seq_name VARCHAR(50)) RETURNS int(11)
    DETERMINISTIC
BEGIN
     DECLARE dtCurrent DATE;
         SET dtCurrent = CURRENT_DATE();
         UPDATE sequence2
                   SET current_value = current_value + increment
                   WHERE NAME = seq_name AND seq_date = dtCurrent;
         RETURN currval_today(seq_name);
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `queryChildrenAreaInfo`
-- ----------------------------
DROP FUNCTION IF EXISTS `queryChildrenAreaInfo`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `queryChildrenAreaInfo`(areaId int(20)) RETURNS varchar(4000) CHARSET utf8
BEGIN
DECLARE sTemp VARCHAR(4000);
DECLARE sTempChd VARCHAR(4000);

SET sTemp = '$';
SET sTempChd = cast(areaId as char);

WHILE sTempChd is not NULL DO
SET sTemp = CONCAT(sTemp,',',sTempChd);
SELECT group_concat(id) INTO sTempChd FROM s_dept where FIND_IN_SET(parent_id,sTempChd)>0 and is_deleted=0;
END WHILE;
return sTemp;
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `setval`
-- ----------------------------
DROP FUNCTION IF EXISTS `setval`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `setval`(seq_name VARCHAR(50), VALUE INTEGER) RETURNS int(11)
    DETERMINISTIC
BEGIN
         UPDATE sequence
                   SET current_value = VALUE
                   WHERE NAME = seq_name;
         RETURN currval(seq_name);
END
 ;;
delimiter ;

-- ----------------------------
--  Function structure for `setval_today`
-- ----------------------------
DROP FUNCTION IF EXISTS `setval_today`;
delimiter ;;
CREATE DEFINER=`root`@`%` FUNCTION `setval_today`(seq_name VARCHAR(50), VALUE INTEGER) RETURNS int(11)
    DETERMINISTIC
BEGIN
     DECLARE dtCurrent DATE;
         SET dtCurrent = CURRENT_DATE();
         UPDATE sequence2
                   SET current_value = VALUE, seq_date = dtCurrent
                   WHERE NAME = seq_name;
         RETURN currval_today(seq_name);
END
 ;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
